/**
 * Descriptions：主页详情页
 * <p>
 * Author：ChenME
 * Date：2017/6/26
 * Email：ibelieve1210@163.com
 */
import React, {Component} from 'react';
import {
    StyleSheet,
    Text,
    View,
    Platform,
    WebView,
} from 'react-native';

export default class CMEHomeDetail extends Component {

    static navigationOptions = props=> {

        const {navigation} = props;
        const {state, setParams} = navigation;
        const {params} = state;

        return {
            title: params.data.title,
            headerTintColor: '#fff',//返回箭头的颜色
            headerStyle: {
                backgroundColor: '#ff639b',
                height: Platform.OS === 'ios' ? 71 : 49,
            },
            headerTitleStyle: {
                color: '#fff',
            },
            headerBackTitleStyle: {
                color: '#fff',
            },
        }
    };


    // static navigationOptions = {
    //     title: '首页',
    //     headerTintColor: '#fff',//返回箭头的颜色
    //     headerStyle: {
    //         backgroundColor: '#ff639b',
    //         height: Platform.OS === 'ios' ? 71 : 49,
    //     },
    //     headerTitleStyle: {
    //         color: '#fff',
    //     },
    //     headerBackTitleStyle: {
    //         color: '#fff',
    //     },
    // };

// <key>www.baidu.com</key>
// <dict>
// <key>NSExceptionAllowsInsecureHTTPLoads</key>
// <true/>
// <key>NSExceptionRequiresForwardSecrecy</key>
// <true/>
// <key>NSIncludesSubdomains</key>
// <true/>
// </dict>

    render() {
        const {params} = this.props.navigation.state;
        const {goBack} = this.props.navigation;
        // const realUrl = this.dealWithUrl(params.data.detailUrl) ;
        // + 'uuid=5C7B6342814C7B496D836A69C872202B5DE8DB689A2D777DFC717E10FC0B4271&utm_term=6.6&utm_source=AppStore&utm_content=5C7B6342814C7B496D836A69C872202B5DE8DB689A2D777DFC717E10FC0B4271&version_name=6.6&userid=160495643&utm_medium=iphone&lat=23.134709&utm_campaign=AgroupBgroupD100Ghomepage_shoppingmall_detailH0&token=b81UqRVf6pTL4UPLLBU7onkvyQoAAAAAAQIAACQVmmlv_Qf_xR-hBJVMtIlq7nYgStcvRiK_CHFmZ5Gf70DR47KP2VSP1Fu5Fc1ndA&lng=113.373890&f=iphone&ci=20&msid=0FA91DDF-BF5B-4DA2-B05D-FA2032F30C6C2016-04-04-08-38594';
        // +'uuid=5C7B6342814C7B496D836A69C872202B5DE8DB689A2D777DFC717E10FC0B4271&msid=0FA91DDF-BF5B-4DA2-B05D-FA2032F30C6C2016-04-04-08-38594&utm_term=6.6&utm_source=AppStore&latlng=23.134643%2C113.373951&utm_content=5C7B6342814C7B496D836A69C872202B5DE8DB689A2D777DFC717E10FC0B4271&userid=160495643&utm_medium=iphone&movieBundleVersion=100&version_name=6.6&__skck=3c0cf64e4b039997339ed8fec4cddf05&__skua=5657981d60b5e2d83e9c64b453063ada&__skts=1459731016.429482&utm_campaign=AgroupBgroupD100H0&__skno=7486F945-8EC1-41B1-9EDC-C9562F04B760&__skcy=NR8eXbF1J1yURHvLvYJrgy3Wnhk%3D&ci=20&__vhost=api.mobile.meituan.com&client=iphone';
        // const realUrl = 'http://www.baidu.com';
        const realUrl = 'http://www.qq.com/';
        return (

            <View style={styles.pageViewStyle}>
                <Text onPress={()=>goBack()}>主页面详情~~~{params.data.detailUrl}</Text>

                <WebView
                    automaticallyAdjustContentInsets={true}
                    source={{uri: realUrl}}
                    javaScriptEnabled={true}
                    domStorageEnabled={true}
                    decelerationRate="normal"
                    startInLoadingState={true}
                />

            </View>
        );
    }

    //处理URL
    dealWithUrl(fullUrl) {
        return fullUrl.replace('imeituan://www.meituan.com/web/?url=', '');
    }
}

const styles = StyleSheet.create({
    pageViewStyle: {
        flex: 1,
    },
});